const unit = (function () {
	function parseUrl(url){
         var result = {};
         var keys = ['href','origin','protocol','host','hostname','port','pathname','search','hash'];
         var regexp = /(([^:]+:)\/\/(([^:\/\?#]+)(:\d+)?))(\/[^?#]*)?(\?[^#]*)?(#.*)?/;
         var match = regexp.exec(url);
         if(match){
             for(var i=keys.length-1;i>=0;i--){
                 result[keys[i]] = match[i]?match[i]:' ';
             }
         }
         return result;
    }
	function each (arr,fn) {
		let i = 0,
			len = arr.length;
		while(i<len){
			if(typeof fn == 'function'){
				var ret = fn.call(this,arr[i],i);
				if(ret != 'undefined' && (ret == null || ret == false)){break;}
			}
			i++;
		}
	}
	function pathCheck (routerPath) {
		var reg = /\/{1}[\s\S]/;
		if(!(reg.test(routerPath) || routerPath == '/' || routerPath == '*')){
			throw routerPath+'格式书写错误'
		}
	}
	function extend (subClass,superClass){
		debugger
	   var F = function (){};
	   F.prototype = superClass.prototype;
	   subClass.prototype = new F();
	   subClass.prototype.constructor = subClass;
	   subClass.super = superClass.prototype; 
//	   if(superClass.prototype.constructor === Object.prototype.constructor){superClass.prototype.constructor = superClass};	
	}
	
	function mixin(receveClass,giveClass){
	  for(var method in giveClass){
		if(!receveClass.__proto__[method]){
	        receveClass.__proto__[method] = giveClass.__proto__[method];
		}
	  }
	  receveClass.__proto__.constructor= receveClass;
	}
	function path (path) {
		let _path = '';
			if(typeof path == 'object' && Object.prototype.toString(path) == '[object Object]' && path.path){
				_path=path.path;
			}else{
				_path = path
			}
		return _path;	
	}
	function query (path) {
		var result = {};
	    if(location.search){
	    	var Tempurl = location.search.slice(1).split('&');
	    }else{return;}
		len = Tempurl.length;
	    for (var i  =0;i<len;i++) {
	    	var tempData = Tempurl[i].split('=');
	    	result[tempData[0]] = tempData[1];
	    }
	    return result;
	}
    return {
    	parseUrl:parseUrl,
    	each:each,
    	pathCheck:pathCheck,
    	mixin:mixin,
    	extend:extend,
    	path:path,
    	query:query
    }
})();
	     
         


